<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<p>This tests for a bug where left justifying a paragraph amongst several that are centered would left justify all of them.  Only the second paragraph should be left justified. </p>
<div id="sample" contenteditable="true" style="text-align:center;">foo<br>bar<div id="end">baz</div></div>
<div id="log"></div>
<script>
test(function() {
    var selection = window.getSelection();
    var sample = document.getElementById('sample');

    selection.collapse(sample, 2);
    selection.extend(document.getElementById('end'), 0);
    document.execCommand('justifyLeft');

    assert_equals(sample.innerHTML, 'foo<br><div style="text-align: left;">bar</div><div id="end" style="text-align: left;">baz</div>', 'innerHTML');
    assert_false(selection.isCollapsed, 'isCollapsed');
    assert_equals(selection.anchorNode, sample.childNodes[2].firstChild, 'anchorNode');
    assert_equals(selection.anchorOffset, 0, 'anchorOffset');
    assert_equals(selection.focusNode, document.getElementById('end'), 'focusNode');
    assert_equals(selection.focusOffset, 0, 'focusOffset');
});
</script>
